package com.shushan.accessibility.flyme;

import com.shushan.accessibility.AccessibilityOperator;

/**
 * @ClassName: FlymeOperator
 * @Desciption: Flyme辅助功能操作类
 * @author: yichaohua
 * @date: 2018-08-22
 */
public class FlymeOperator {

    private static final String TAG = "FlymeOperator";

    private static FlymeOperator mInstance = new FlymeOperator();

    public static FlymeOperator getInstance() {
        return mInstance;
    }

    public boolean openComplete() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        boolean result = AccessibilityOperator.getInstance().clickListItem("com.meizu.safe:id/list","书山宝",1);
        if(!result){
            return false;
        }else {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return AccessibilityOperator.getInstance().clickByText("允许后台运行");
        }
    }

    public boolean openFloatManager() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return AccessibilityOperator.getInstance().clickListCustomView("com.meizu.common.widget.Switch","悬浮窗",1,true);
    }

    public boolean enableAdmin() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return AccessibilityOperator.getInstance().clickByText("激活此设备管理员");
    }

    public boolean openUsageSetting() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        boolean result = AccessibilityOperator.getInstance().clickListItem("书山宝",1);
        if(!result){
            return false;
        }else {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return AccessibilityOperator.getInstance().clickOnlyCustom("com.meizu.common.widget.Switch",true);
        }
    }
}
